pub use crate::prelude::*;
use std::collections::HashSet;

#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Render {
    pub color: ColorPair,
    pub glyph: FontCharType,
}

#[derive(Copy, Clone, Debug, PartialEq)]
/// Player是一个不包含任何数据的空结构体。它充当一个“标签”的角色，指示包含这个组件的实体是玩家角色对应的实体。
pub struct Player{
    pub map_level: u32,
}

#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Enemy;

#[derive(Copy, Clone, Debug, PartialEq)]
pub struct MovingRandomly;

#[derive(Copy, Clone, Debug, PartialEq)]
pub struct WantsToMove {
    pub entity: Entity,
    pub destination: Point,
}

#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Health{
    pub current: i32,
    pub max: i32,
}

#[derive(Clone, PartialEq)]
pub struct Name(pub String);

#[derive(Clone, Copy, Debug, PartialEq)]
pub struct WantsToAttack {
    /// 攻击者
    pub attacker: Entity,
    /// 受害者
    pub victim: Entity,
}

/// 追逐玩家角色
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct ChasingPlayer;

/// 实体是一件物品，物品不会移动，也没有生命值，但仍然要被渲染出现在地图上
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Item;

/// 被标记的物品是用来赢得游戏的那个物品
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct AmuletOfYala;

/// 可见的图块
#[derive(Clone, Debug, PartialEq)]
pub struct FieldOfView {
    pub visible_tiles: HashSet<Point>,
    /// 每个方向上可以看到多少个图块
    pub radius: i32,
    /// 是否是脏数据
    pub is_dirty: bool,
}

impl FieldOfView {
    pub fn new(radius: i32) -> Self {
        return Self {
            visible_tiles: HashSet::new(),
            radius,
            is_dirty: true,
        };
    }

    pub fn clone_dirty(&self) -> Self {
        return Self {
            visible_tiles: HashSet::new(),
            radius: self.radius,
            is_dirty: true,
        }
    }
}

/// 疗伤药水
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct ProvidesHealing {
    /// 可以恢复的生命值
    pub amount: i32,
}

/// 表示这个物品处于激活状态并且正在发挥作用
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct ProvidesDungeonMap;

/// 表示另一个实体携带着当前物品
#[derive(Clone, PartialEq)]
pub struct Carried(pub Entity);

#[derive(Clone, Copy, Debug, PartialEq)]
pub struct ActivateItem {
    pub used_by: Entity,
    pub item: Entity,
}

/// 伤害值组件
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Damage(pub i32);


/// 武器
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Weapon;